<?php
session_start();
include('inc/connection.php');

?>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>

<script>
function initialize()
{
var mapProp = {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
  
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
function myFunction()
{
document.getElementById("googleMap").style.visibility="hidden";
}
</script>
</head>

<body>

</body>

<?php

if ( isset( $_GET['action'] ) )
	$action = $_GET['action'];
else
	$action = 'def';



//add, update
switch( $action )
{
	case 'def' :
	
		
    	   $sql = "SELECT * FROM `products` WHERE status=1 AND category = 1";


	
	break;
	
	case 'update' :
            
    	   $sql = "SELECT * FROM `products` WHERE status=1 AND category = " . $_GET['id'];

		?> 
           <script>
//				window.location.href = 'viewAllProducts.php';
			</script>
        <?php
			
			
	
	break;
}
?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="Hasan" content="EC" />
        <!--  CSS   -->
        <link href="css/en/mycss.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/header.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/footer.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/products.css" rel="Stylesheet" type="text/css" />
        <link rel="shortcut icon" href="favicon.ico" />
    <!--  JS   -->
        <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="js/header.js"></script>
        <script src="js/products.js"></script>


        <title>Mobizoo Mobiles - Products</title>
    </head>

    <!-- BODY -->
    <body>
	

        <div id="opacityDiv">

        </div>
        <div class="infoDiv">
        </div>
        <!-- ********************************* -->
        <!-- header -->
        <!-- ********************************* -->
        <?php
        include('inc/header.php');
        ?>

        <!-- ********************************* -->
        <!-- slider -->
        <!-- ********************************* -->
		
		<div id = "m">
		<div id='cssmenu'>
				<ul>
		
				<li class='active '><a href="products.php?action=update&id=1"><span>Samsung</span></a></li>
				<li><a href="products.php?action=update&id=2"><span>Nokia</span></a></li>
				<li><a href="products.php?action=update&id=3"><span>Apple</span></a></li>
				<li><a href="products.php?action=update&id=4"><span>Sony</span></a></li>
					</ul>
                    
                                        
			</div>
                    <br/><br/><br/>
                    <a href='weather'> Weather Service <a/><br/>
                                    <a href='javascript:myFunction()'> Hide Map! <a/>
                                    <div id="googleMap" style="width:200px;height:220px;"></div>
                                      


		</div>
        <div id="container">
            <!--            <div id="catrgoriesArea">
                            <div id="catrgoriesTitle">
                                <h2>Categories</h2>
                            </div>
            
                        </div>-->

            <!--*****************************************************************-->
            <!--*****************************************************************-->
            <!--products view-->
            <div id="productsArea">
                <?php
                $inCart = false;
                                $result = mysql_query($sql);
                
                if (!($row = mysql_fetch_array($result))) {
                   
                        echo '<h3 style="color:white;">No Products ...</h3>';
                }else{
				
				
				/////////////////////////////////////////////////////////////////////////////
				 $productPrice = $row['price'];
					
					
                    echo '<div class="productSlice">
                        <div class="productSliceImage">
                            <img src="../photos/thumb/' . $row['img'] . '" width="90px" height = "110px" alt=""/>
                        </div>
                        <div class="productSliceInfo">
                            <h2>' . $row['name_en'] . '</h2>
                            <h3>'. '$'. $productPrice. '</h3>
                        </div>
                        ';
                    if (!isset($_SESSION['id'])) {
                        echo '<div class="productSliceButtons">
                            
                            <p style="float:left;display:block; margin:auto; text-align: center; width:50px; border-radius:3px; background-color:brown; color:white;">login</p>
                            <input type="button" value="info" class="info" ="' . $row['id'] . '"/>
                            </div>
                            </div>';
                    } else {

					  $arrlength=count($_SESSION['cart']);

						for($x=0;$x<$arrlength;$x++){
						
						$arr = explode("," ,$_SESSION['cart'][$x]);
							if($arr[0] == $row['id']){
								$inCart = true;
						
		
							}
						}
						
						if ($inCart) {
                            echo '<div class="productSliceButtons">
                            
                            <input type="button" value="delete" class="delete"  content="' . $row['id'] . '"/>
                            <input type="button" value="View" class="info" content="' . $row['id'] . '"/>
                            </div>
                            </div>';
                            $inCart = false;
							
						}else {
						
								
					  echo '<div class="productSliceButtons">

                                <input type="button" value="add" class="buy"  content="' . $row['id'] . '"/>
                                <input type="button" value="View" class="info" content="' . $row['id'] . '"/>
                            </div>
                            </div>';
						}
                          
                        
                    }
					///////////////////////////////////////////////////////////////////////////
                }

                while ($row = mysql_fetch_array($result)) {
                    $productPrice = $row['price'];
					
					
                    echo '<div class="productSlice">
                        <div class="productSliceImage">
                            <img src="../photos/thumb/' . $row['img'] . '" width="90px" height = "110px" alt=""/>
                        </div>
                        <div class="productSliceInfo">
                            <h2>' . $row['name_en'] . '</h2>
                            <h3>'. '$'. $productPrice. '</h3>
                        </div>
                        ';
                    if (!isset($_SESSION['id'])) {
                        echo '<div class="productSliceButtons">
                            
                            <p style="float:left;display:block; margin:auto; text-align: center; width:50px; border-radius:3px; background-color:brown; color:white;">login</p>
                            <input type="button" value="info" class="info" ="' . $row['id'] . '"/>
                            </div>
                            </div>';
                    } else {

					  $arrlength=count($_SESSION['cart']);

						for($x=0;$x<$arrlength;$x++){
						
						$arr = explode("," ,$_SESSION['cart'][$x]);
							if($arr[0] == $row['id']){
								$inCart = true;
						
		
							}
						}
						
						if ($inCart) {
                            echo '<div class="productSliceButtons">
                            
                            <input type="button" value="delete" class="delete"  content="' . $row['id'] . '"/>
                            <input type="button" value="View" class="info" content="' . $row['id'] . '"/>
                            </div>
                            </div>';
                            $inCart = false;
							
						}else {
						
								
					  echo '<div class="productSliceButtons">

                                <input type="button" value="add" class="buy"  content="' . $row['id'] . '"/>
                                <input type="button" value="View" class="info" content="' . $row['id'] . '"/>
                            </div>
                            </div>';
						}
                          
                        
                    }
                }
                
                
                ?>        
            </div>
        </div>

        <!-- ********************************* -->
        <!-- footer -->
        <!-- ********************************* -->
        <?php
        //include('inc/footer.php');
        ?>

    </body>
</html>